let path = require("path");
function resolve(dir) {
  console.log(__dirname);
  return path.join(__dirname, dir);
}
const { defineConfig } = require("@vue/cli-service");
module.exports = defineConfig({
  transpileDependencies: true,
  publicPath: process.env.NODE_ENV === "production" ? "./" : "/", //后端或者运维把你打包后的文件部署到服务器上时的路径， 会影响到资源的路径,合理的使用<%= BASE_URL %>
  filenameHashing: true, //文件名hash值 以public里面的静态资源和assets里面的静态资源举例,如果重名 会覆盖.
  assetsDir: "./static", //静态资源输出目录
  chainWebpack: (config) => {
    config.resolve.alias //路径别名
      .set("@", resolve("./src"))
      .set("@assets", resolve("./src/assets"))
      .set("@icon", resolve("./src/assets/icon"))
      .set("@img", resolve("./src/assets/images"))
      .set("@components", resolve("./src/components"))
      .set("@views", resolve("./src/views"))
      .set("@utils", resolve("./src/utils"));
  },
  css: {
    extract: true,
    sourceMap: true,
  },

  devServer: {
    // client: { //不提示报错
    //   overlay: false,  
    // },
    proxy: {
      "/api": {
        target: "http://localhost:8089", // 需要代理的目标地址
        changeOrigin: true, // 将主机标头的原点更改为目标URL
        pathRewrite: {
          "^/api": "", // 重写路径，将请求中的 /api 替换为空字符串
        },
      },
    },
  },
});
